public class of13 {
    public static void main(String[] args) {
        of13 of = new of13();
        System.out.println(of.movingCount(3, 1, 0));
        
    }

    public int movingCount(int m, int n, int k) {
        char a[][]=new char[n][m];
        int all=0;
        dfs(a, 0, 0, n, m, k);
        return all;
    }
    static boolean dfs(char a[][],int i,int j,int n,int m,int k){
        s
        if(i<0||i>=n||j<0||j>=m||a[i][j]=='k'){
            return false;
        }
        
        int e=0;
        int i1=i,j1=j;
        while(i1>0||j1>0){
            e+=e+i1%10+j1%10;
            i1=i1/10;
            j1=j1/10;
        }
        boolean res;
        if(e>k){
            return false;
        }else {
            all++;
            a[i][j]='k';
            res=dfs(a, i+1, j, n, m, k)||dfs(a, i-1, j, n, m, k)||dfs(a, i, j+1, n, m, k)||dfs(a, i, j-1, n, m, k);
        }
        return  res;
        
    }
}
